home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 15 / CU Amiga Magazine's Super CD-ROM 15 (1997)(EMAP Images)(GB)[!][issue 1997-10].iso / CUCD / Graphics / Gallery / Source / InformationWindow.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1997-07-15  |  3.2 KB  |  142 lines

  1. #include <stream.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <ctype.h>
  5. #include <stdio.h>
  6.  
  7. #include "GUICINCLUDE:GUIC_Screen.hpp"
  8. #include "GUICINCLUDE:GUIC_Application.hpp"
  9. #include "GUICINCLUDE:GUIC_GGFXPicture.hpp"
  10. #include "GUICINCLUDE:GUIC_Button.hpp"
  11. #include "GUICINCLUDE:GUIC_Text.hpp"
  12. #include "GUICINCLUDE:GUIC_Frame.hpp"
  13. #include "GUICINCLUDE:GUIC_Event.hpp"
  14. #include "GUICINCLUDE:GUIC_Exceptions.hpp"
  15. #include "GUICINCLUDE:GUIC_FileExamine.hpp"
  16. #include "GUICINCLUDE:GUIC_Error.hpp"
  17.  
  18. #include "InformationWindow.hpp"
  19.  
  20. /*********************************************************************************************************/
  21.  
  22. InformationWindowC::InformationWindowC     (GUIC_ApplicationC &a, GUIC_ScreenC &s) : GUIC_WindowC (-1,-1,63,28)
  23. {
  24.     app         = &a;
  25.     screen    = &s;
  26.     pic1        = 0;
  27.     pic2        = 0;
  28.     
  29.     frame1    = new GUIC_FrameC        ( 1, 1,30,26, "Picture To Be Copied");
  30.     frame2    = new GUIC_FrameC        (32, 1,30,26, "Existing Picture");
  31.     text1        = new GUIC_TextC            ( 2,24,28, 2, "");
  32.     text2        = new GUIC_TextC            (33,24,28, 2, "");
  33.     
  34.     text1->setBorder(FALSE);
  35.     text2->setBorder(FALSE);
  36.     
  37.     text1->setJustification(GUIC_Center);
  38.     text2->setJustification(GUIC_Center);
  39.     
  40.     add (frame1);
  41.     add (frame2);
  42.     add (text1);
  43.     add (text2);
  44.     
  45.     app->addPrefs("InformationWindow",    this);
  46.  
  47.     setGuideContext("InformationWindow");
  48.     setTitle ( "Information" );
  49.  
  50.     activate();
  51. }
  52. InformationWindowC::~InformationWindowC    (VOID)
  53. {
  54.     cleanUp();
  55. }
  56.  
  57. /*********************************************************************************************************/
  58.  
  59. STRPTR    InformationWindowC::getClass        (VOID)
  60. {
  61.     return "InformationWindowC";
  62. }
  63.  
  64. BOOL        InformationWindowC::action            (GUIC_EventC &e)
  65. {
  66.     switch (e.id)
  67.         {
  68.         case GUIC_OpenWindow:
  69.             return TRUE;
  70.             break;
  71.         case GUIC_CloseWindow:
  72.             if (pic1) { remove(pic1); delete pic1; pic1=0; }
  73.             if (pic2) { remove(pic2); delete pic2; pic2=0; }
  74.             text1->set("");
  75.             text2->set("");
  76.             screen->remove(this);
  77.             return TRUE;
  78.             break;
  79.         }
  80.     
  81.     return FALSE;
  82. }
  83.  
  84. VOID         InformationWindowC::setPictures    (STRPTR fileName1, STRPTR fileName2)
  85. {
  86.     CHAR buffer[100];
  87.  
  88.     sleep();
  89.  
  90.     if (pic1) { remove(pic1); delete pic1; pic1=0; }
  91.     if (pic2) { remove(pic2); delete pic2; pic2=0; }
  92.     
  93.     try
  94.         {
  95.         // Picture 1
  96.         pic1 = new GUIC_GGFXPictureC( 2,2,28,22,fileName1);
  97.  
  98.         pic1->setScaled(TRUE);
  99.         pic1->setCentered(TRUE);
  100.  
  101.         GUIC_FileExamineC f1 (fileName1);
  102.         sprintf(buffer, "%ld x %ld (%ld Bytes)", pic1->getWidth(), pic1->getHeight(), f1.getSize() );
  103.  
  104.         text1->set(buffer);
  105.  
  106.         add (pic1);
  107.  
  108.         // Picture 2
  109.         pic2 = new GUIC_GGFXPictureC(33,2,28,22,fileName2);
  110.  
  111.         pic2->setScaled(TRUE);
  112.         pic2->setCentered(TRUE);
  113.  
  114.         GUIC_FileExamineC f2 (fileName2);
  115.         sprintf(buffer, "%ld x %ld (%ld Bytes)", pic2->getWidth(), pic2->getHeight(), f2.getSize() );
  116.         text2->set(buffer);
  117.  
  118.         add (pic2);    
  119.         }
  120.     catch (GUIC_Exception &e)
  121.         {
  122.         GUIC_ErrorC err ("Exception caught:", e.getMessage() );
  123.         err.request(this);
  124.         }
  125.     
  126.     waken();
  127. }
  128.  
  129. /*********************************************************************************************************/
  130.  
  131. VOID         InformationWindowC::cleanUp            (VOID)
  132. {    
  133.     if (pic1) { remove(pic1); delete pic1; pic1=0; }
  134.     if (pic2) { remove(pic2); delete pic2; pic2=0; }
  135.  
  136.     delete frame1;
  137.     delete frame2;
  138.     delete text1;
  139.     delete text2;    
  140. }
  141.  
  142.